function showRegisterForm(){
    $('.loginBox').fadeOut('fast',function(){
        $('.registerBox').fadeIn('fast');
        $('.login-footer').fadeOut('fast',function(){
            $('.register-footer').fadeIn('fast');
        });
        $('.modal-title').html('ChangePW with');
    }); 
    $('.error').removeClass('alert alert-danger').html('');
       
}
function showLoginForm(){
    $('#loginModal .registerBox').fadeOut('fast',function(){
        $('.loginBox').fadeIn('fast');
        $('.register-footer').fadeOut('fast',function(){
            $('.login-footer').fadeIn('fast');    
        });
        
        $('.modal-title').html('Register with');
    });       
     $('.error').removeClass('alert alert-danger').html(''); 
}

function openLoginModal(){
    showLoginForm();
    setTimeout(function(){
        $('#loginModal').modal('show');    
    }, 230);
    
}
function openRegisterModal(){
    showRegisterForm();
    setTimeout(function(){
        $('#loginModal').modal('show');    
    }, 230);
    
}

function registerAjax(){

//	alert($('#lyy_register').serialize());
	var formData= $.serializeObject($('#lyy_register'));
	console.log(formData.account)
	console.log(formData.password)
	var ajax = new $ax(Feng.ctxPath + "/proce/register", function(data){
		if(data.code==200){
			Feng.success(data.msg);
			$("#autoname").val(formData.account)
			$("#autopwd").val(formData.password)
			$("#autoClick").click();
			/*$.ajax({
			    url:Feng.ctxPath+"/login",    //请求的url地址
			    dataType:"json",   //返回格式为json
			    async:true,//请求是否异步，默认为异步，这也是ajax重要特性
			    data:{"username":formData.account,
			    	  "password":formData.password
			    	 },    //参数值
			    type:"POST",   //请求方式
			    
			    complete:function(){
			    	window.location.reload();
			    }
			})*/
		}else{
			Feng.error(data.msg);
		}
       // window.parent.Bindclient.table.refresh();
       // BindclientInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
	formData['UserType']=$('#UserType').val()
	console.log(formData)
    ajax.set(formData);
    ajax.start();
}


function getBackAjax(){
    /*   Remove this comments when moving to server
    $.post( "/proce/register", function( data ) {
            if(data == 1){
                window.location.replace("/home");            
            } else {
                 shakeModal(); 
            }
        });
    

  Simulate error message from the server   
     shakeModal();*/
//	alert($('#lyy_register').serialize());
	var formData= $.serializeObject($('#lyy_getback'));
	var ajax = new $ax(Feng.ctxPath + "/proce/getbackpw", function(data){
		if(data.code==200){
			console.log($("#autoname").val()+"hello")
			$("#autoname").val(formData.account)
			$("#autopwd").val(formData.password)
			$("#autoClick").click();
			/*Feng.success(data.msg);
			$.ajax({
			    url:Feng.ctxPath+"/login",    //请求的url地址
			    dataType:"json",   //返回格式为json
			    async:true,//请求是否异步，默认为异步，这也是ajax重要特性
			    data:{"username":formData.account,
			    	  "password":formData.password
			    	 },    //参数值
			    type:"POST",   //请求方式
			    
			    complete:function(){
			    	window.location.reload();
			    }
			})*/
		}else{
			Feng.error(data.msg);
		}
        
       // window.parent.Bindclient.table.refresh();
       // BindclientInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(formData);
    ajax.start();
}

function shakeModal(){
    $('#loginModal .modal-dialog').addClass('shake');
             $('.error').addClass('alert alert-danger').html("Invalid email/password combination");
             $('input[type="password"]').val('');
             setTimeout( function(){ 
                $('#loginModal .modal-dialog').removeClass('shake'); 
    }, 1000 ); 
}

   